package studiodiva.portfolio.client.lib.lang;

import com.google.gwt.event.shared.HandlerRegistration;

import studiodiva.portfolio.client.lib.even.Event;
import studiodiva.portfolio.client.lib.even.HasEvents;

class EventRegistration {
  private final Event<?> event;
  private final HandlerRegistration registration;
  private final HasEvents target;

  public EventRegistration(Event<?> event, HasEvents target, HandlerRegistration registration) {
    this.event = event;
    this.target = target;
    this.registration = registration;
  }

  public Event<?> getEvent() {
    return event;
  }

  public HandlerRegistration getRegistration() {
    return registration;
  }

  public HasEvents getTarget() {
    return target;
  }

  public void cancel() {
    registration.removeHandler();
  }
}